import request from '@/utils/request';

// 礼品管理相关接口
// 获取礼品列表
export function getGiftList(params) {
  return request({
    url: '/backend/gift/getGiftList',
    method: 'get',
    params
  });
}

// 获取礼品详情
export function getGiftDetail(id) {
  return request({
    url: `/backend/gift/getGiftDetail`,
    method: 'get',
    params: {
      id
    }
  });
}

// 新增礼品
export function createGift(data) {
  return request({
    url: '/backend/gift/addGift',
    method: 'post',
    data
  });
}

// 更新礼品
export function updateGift(id, data) {
  return request({
    url: `/backend/gift/updateGift`,
    method: 'put',
    data: {
      id,
      ...data
    }
  });
}

// 删除礼品
export function deleteGift(id) {
  return request({
    url: `/backend/gift/deleteGift`,
    method: 'delete',
    data: {
      id
    }
  });
}

// 切换礼品状态（上架/下架）
export function toggleGiftStatus(id, status) {
  return request({
    url: `/backend/gift/toggleStatus`,
    method: 'put',
    data: {
      id,
      status
    }
  });
}

// 兑换记录相关接口
// 获取兑换记录列表
export function getExchangeList(params) {
  return request({
    url: '/backend/gift/getExchangeList',
    method: 'get',
    params
  });
}

// 获取兑换记录详情
export function getExchangeDetail(id) {
  return request({
    url: `/backend/gift/getExchangeDetail`,
    method: 'get',
    params: {
      id
    }
  });
}

// 完成兑换
export function completeExchange(data) {
  return request({
    url: `/backend/gift/updateGiftExchangeLogistics`,
    method: 'put',
    data
  });
}

// 取消兑换
export function cancelExchange(id, reason) {
  return request({
    url: `/backend/gift/cancelExchange`,
    method: 'put',
    data: {
      id,
      reason
    }
  });
}

// 批量处理兑换记录
export function batchProcessExchange(data) {
  return request({
    url: '/backend/gift/batchProcessExchange',
    method: 'put',
    data
  });
}

// 导出兑换记录
export function exportExchangeList(params) {
  return request({
    url: '/backend/gift/exportExchangeList',
    method: 'get',
    params,
    responseType: 'blob'
  });
}

// 分类管理相关接口
// 获取礼品分类列表
export function getGiftCategories() {
  return request({
    url: '/backend/gift/getCategoryList',
    method: 'get'
  });
}

// 新增礼品分类
export function createGiftCategory(data) {
  return request({
    url: '/backend/gift/addCategory',
    method: 'post',
    data
  });
}

// 更新礼品分类
export function updateGiftCategory(id, data) {
  return request({
    url: `/backend/gift/updateCategory`,
    method: 'put',
    data: {
      id,
      ...data
    }
  });
}

// 删除礼品分类
export function deleteGiftCategory(id) {
  return request({
    url: `/backend/gift/deleteCategory`,
    method: 'delete',
    data: {
      id
    }
  });
} 